/*
package com.autonavi.abs.generator.core.db;

import com.autonavi.abs.generator.common.enumeration.DbTypeEnum;
import com.autonavi.abs.generator.common.model.ColumnMeta;
import com.autonavi.abs.generator.common.model.TableMeta;
import com.autonavi.abs.generator.core.property.TddlProperty;
import com.autonavi.abs.generator.util.DbUtil;
import com.taobao.tddl.client.jdbc.TDataSource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;

*/
/**
 * @author wwy
 * @version V1.0
 * <p>Description: tddl DataSource</p>
 * @date 2020-08-10 18:37
 *//*

@Slf4j
@Component
public class TddlMetaDataSource implements MetaDataSource {

    @Autowired
    private TddlProperty tddlProperty;

    private DataSource dataSource;
    private String type = DbTypeEnum.Tddl.getType();

    @Override
    public String getType() {
        return type;
    }

    @Override
    @PostConstruct
    public void initDataSource() {
        TDataSource ds = new TDataSource();
        ds.setAppName(tddlProperty.getApp());
        ds.setDynamicRule(tddlProperty.getSharding());
        ds.setRuleFile(tddlProperty.getRuleFilePath());
        ds.init();
        this.dataSource = ds;
    }

    @Override
    public DataSource getDataSource() {
        if (dataSource == null) {
            initDataSource();
        }
        return dataSource;
    }

    @Override
    public Connection getConnection() throws SQLException {
        DataSource ds = getDataSource();
        Connection connection = ds.getConnection();
        return connection;
    }

    @Override
    public List<ColumnMeta> getColumnList(String tableName) throws Exception {
        Connection connection = getConnection();
        List<ColumnMeta> columnList = DbUtil.getColumnList(connection, tableName);
        return columnList;
    }

    @Override
    public List<TableMeta> getTableList() throws Exception {
        Connection connection = getConnection();
        List<TableMeta> tableList = DbUtil.getTableList(connection);
        return tableList;
    }

}
*/
